using System;
using NUnit.Framework;
using System.IO;
using System.Collections.Generic;

namespace Org.JSON.Test.Deserialization
{
	[TestFixture]
	public class String
	{
		[Test]
		public void Empty ()
		{
			Assert.AreEqual("", (Value.From("\"\"") as Org.JSON.String).Value);
		}


		[Test]
		public void Single()
		{
			Assert.AreEqual("abc", (Value.From("\"abc\"") as Org.JSON.String).Value);
		}

		[Test]
		public void QuoteAnSlashEscape()
		{
			Assert.AreEqual("\\\"", (Value.From("\"\\\\\\\"\"") as Org.JSON.String).Value);
		}

		[Test]
		public void BasicControlEscapes()
		{
			Assert.AreEqual("\n\f\r\b\t", (Value.From("\"\\n\\f\\r\\b\\t\"") as Org.JSON.String).Value);
		}

		[Test]
		public void AcceptInvertSlash()
		{
			Assert.AreEqual("//", (Value.From("\"\\//\"") as Org.JSON.String).Value);
		}

		[Test]
		public void UnicodeEscape()
		{
			Assert.AreEqual("\u1234", (Value.From("\"\\u1234\"") as Org.JSON.String).Value);
		}

		[Test]
		[ExpectedException(typeof(InvalidDataException))]
		public void InvalidControlChar()
		{
			Value.From("\"\n\"");
		}
	}
}

